package com.lagou;

/**
 * @description: Http协议头工具类
 * @author: yx
 * @date: 2021/8/31 17:47
 */
public class HttpProtocolUtils {


    /**
     * 获取状态为200请求头信息
     *
     * @param contentLength
     * @return
     */
    public static String getHttpHeader200(long contentLength) {
        return "Http/1.1 200 OK \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + contentLength + " \n" +
                "\r\n";
    }

    /**
     * 获取状态为200请求头信息
     *
     * @return
     */
    public static String getHttpHeader404() {
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n" +
                "Content-Type: text/html \n" +
                "Content-Length: " + str404.getBytes().length + " \n" +
                "\r\n" + str404;
    }
}
